// FieldRule 检验类型
import type { FieldRule } from 'vant'
// 校验手机号规则
const mobileRules: FieldRule[] = [
  { required: true, message: '请输入手机号' },
  {
    pattern: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/,
    message: '手机号不正确'
  }
]

//检验密码规则
const passwordRules: FieldRule[] = [{ required: true, message: '请输入密码' }]

// 校验验证码规则
const codeRules: FieldRule[] = [
  { required: true, message: '请输入验证码' },
  { pattern: /^\d{6}$/, message: '请输入6位数的短信验证码' }
]

// 患者身份证号码校验
const idCardRule: FieldRule[] = [
  { required: true, message: '请输入身份证号' },
  {
    pattern:
      /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/,
    message: '请输入正确的身份证号'
  }
]

// 患者姓名校验
const nameRules: FieldRule[] = [
  { required: true, message: '请输入姓名' },
  { pattern: /^(?:[\u4e00-\u9fa5·]{2,16})$/, message: '请输入正确的姓名' }
]

//导出
export { mobileRules, passwordRules, codeRules, idCardRule, nameRules }
